/**
 * @(#) ReqWelfareMediator.as
 *
 * @date		2009. 03. 19.
 * @version		1.0
 * @author		Shin, Yunwoo
 * @description	복리후생 - 선택적복리후생 신청 - Mediator
 * 				선택적 복리후생 신청 Presentation Logic을 관리 
 */
package com.skt.common_hr.welfare.view
{
	import com.skt.common_hr.common.Variables;
	import com.skt.common_hr.common.approval.RequestApprovalMediator;
	import com.skt.common_hr.common.components.CommonAlert;
	import com.skt.common_hr.common.puremvc.CommonMediator;
	import com.skt.common_hr.welfare.WelfareFacade;
	import com.skt.common_hr.welfare.events.ChangedAccountEvent;
	import com.skt.common_hr.welfare.events.WelfareItemEvent;
	import com.skt.common_hr.welfare.model.BankAccountProxy;
	import com.skt.common_hr.welfare.model.WelfareApprovalProxy;
	import com.skt.common_hr.welfare.model.WelfareCodesProxy;
	import com.skt.common_hr.welfare.model.WelfareDetailProxy;
	import com.skt.common_hr.welfare.model.WelfareYearProxy;
	import com.skt.common_hr.welfare.model.vo.BankAccountVO;
	import com.skt.common_hr.welfare.model.vo.ReqWelfareVO;
	import com.skt.common_hr.welfare.view.components.BankAccountView;
	import com.skt.common_hr.welfare.view.components.ReqWelfare;
	import com.wcl.utils.DateUtil;
	import com.wcl.utils.NumberUtil;
	import com.wcl.utils.StringUtil;
	
	import flash.events.Event;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	
	public class ReqWelfareMediator extends CommonMediator
	{
		public static const NAME:String = "ReqWelfareMediator"; 
		public var defaultBank:BankAccountVO = null;
	    public var additionBank:BankAccountVO = null;
	    private var VALIDATION_MSG:String = "";

		public var Gkey:String;
		public var restMoney:Number = 0;

		public var cbYear:String; //20120102
		
		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function ReqWelfareMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );
            
        }
 		
		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
		override protected function initializeView():void
 		{
 			
 			setCodeList(); 
 			view.bankAccount = getBankInfo(0);
 			// 각 버튼들의 Event Handler를 설정하고
 			view.addEventListener(ReqWelfare.CANCEL_WELFARE, onCancel);
 			view.addEventListener(ReqWelfare.CONFIRM_WELFARE, onConfirm);
 			view.addEventListener(ReqWelfare.APPROVAL_WELFARE, onApproval);
 			
 			
 			view.addEventListener(ReqWelfare.ADD_RECORD, onClickAddRecord);
 			view.addEventListener(ReqWelfare.DEL_RECORD, onDelRecord);
 			view.addEventListener(ReqWelfare.OPEN_ACCOUNT_CONTROL, onOpenAccountControl);
 			view.addEventListener(ChangedAccountEvent.CHANGED_ACCOUNT, onChangedAccount);
 			view.addEventListener(WelfareItemEvent.WELFARE_ITEM_DEL, itemDel);
 			//view.addEventListener(ReqWorkTimeView.DEL_RECORD, onDelRecord);
 			if(Gkey == null || Gkey == ""){
 				//cleanView();
 			}
 		}
 		
 		public function updateDataSet():void {
 			if(Gkey == null || Gkey == ""){
 				cleanView();
 			}else{
 				onSelectedWelFareDetail();
 			} 			
 		}
 		
 		/***
 		 * 신규입력시 화면 초기화
 		 * **/
 		public function cleanView():void{
 			view.welfareDetailList.removeAll();
 			 
/*   			if(view.cbType) {
 				view.cbType.selectedIndex = 0;
 				bankInfoLoad(view.cbType.selectedIndex); 				
 			}  */
			
 			
 			
 			/* view.T_BELNR.text = "";
 			view.T_BSTATX.text = "";
 			view.T_DSTATX.text = ""; */
 			addRecord();
 		} 
 		
 		/**
 		 * 사용유형, 항목, 거래처정보, 거래 결재정보 데이터 담기
 		 * **/
 		private function setCodeList():void
 		{
 			var proxy:WelfareCodesProxy = facade.retrieveProxy(WelfareCodesProxy.NAME) as WelfareCodesProxy;
 			view.usedClassList = proxy.usedClassList;
 			view.usedItemList = proxy.usedItemList;
 			view.patronInfo = proxy.patronInfo;
 			view.tradeInfo = proxy.tradeInfo;
 		}
 		
 		
 		 private function getBankInfo(gubun:int):BankAccountVO
 		{
 			var proxy:BankAccountProxy = facade.retrieveProxy(BankAccountProxy.NAME) as BankAccountProxy;
 			if(proxy.additionBank != null) {
 				return proxy.additionBank;
 			}
 			else {
 				return proxy.defaultBank;
 			}
/*  			
 			if(gubun==0) {
 				return proxy.defaultBank;
 			}
 			else {
 				return proxy.additionBank;
 			 }
*/ 			 
 			
 		} 
 		
 		/***
 		 * 계좌선택 체인지 이벤트
 		 * **/
 		private function onChangedAccount(event:ChangedAccountEvent):void
 		{
 			bankInfoLoad(event.index);
 		}
 		
 		private function bankInfoLoad(idx:int=0):void{
 			return;
 			
			var _defaultBank:BankAccountVO;
			var _additionBank:BankAccountVO;
			if(this.defaultBank == null || this.additionBank == null){
				_defaultBank = (facade.retrieveProxy(BankAccountProxy.NAME) as BankAccountProxy).defaultBank;
				_additionBank = (facade.retrieveProxy(BankAccountProxy.NAME) as BankAccountProxy).additionBank;
			}else{
				_defaultBank = (facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy).defaultBank;
				_additionBank = (facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy).additionBank;
			}
			
			//0 : 급여계좌, 2 : 기타계좌
			if(_additionBank != null) {
				view.detailMaster.BANKA = _additionBank.BANKA;
	 			view.detailMaster.BANKN = _additionBank.BANKN;
	 			view.detailMaster.BANKN = _additionBank.BANKN;
	 			view.detailMaster.BANKL = _additionBank.BANKL;
	 			view.detailMaster.EMFTX = _additionBank.EMFTX;				
			} else if(_defaultBank != null) {
				view.detailMaster.BANKA = _defaultBank.BANKA;
	 			view.detailMaster.BANKN = _defaultBank.BANKN;
	 			view.detailMaster.BANKN = _defaultBank.BANKN;
	 			view.detailMaster.BANKL = _defaultBank.BANKL;
	 			view.detailMaster.EMFTX = _defaultBank.EMFTX;				
			} else {
				view.detailMaster.BANKA = "";
	 			view.detailMaster.BANKN = "";
	 			view.detailMaster.BANKN = "";
	 			view.detailMaster.BANKL = "";
	 			view.detailMaster.EMFTX = "";				
			}
			
			/* 
			if(view.cbType.dataProvider[idx]!=null&& view.cbType.dataProvider[idx].CODE == "0" && _defaultBank != null){
				view.detailMaster.BANKA = _defaultBank.BANKA;
	 			view.detailMaster.BANKN = _defaultBank.BANKN;
	 			view.detailMaster.BANKN = _defaultBank.BANKN;
	 			view.detailMaster.BANKL = _defaultBank.BANKL;
	 			view.detailMaster.EMFTX = _defaultBank.EMFTX;
			}else if(view.cbType.dataProvider[idx]!=null&& view.cbType.dataProvider[idx].CODE == "2" && _additionBank != null){
				view.detailMaster.BANKA = _additionBank.BANKA;
	 			view.detailMaster.BANKN = _additionBank.BANKN;
	 			view.detailMaster.BANKN = _additionBank.BANKN;
	 			view.detailMaster.BANKL = _additionBank.BANKL;
	 			view.detailMaster.EMFTX = _additionBank.EMFTX;
			}else{
				view.detailMaster.BANKA = "";
	 			view.detailMaster.BANKN = "";
	 			view.detailMaster.BANKN = "";
	 			view.detailMaster.BANKL = "";
	 			view.detailMaster.EMFTX = "";
			 }
			*/
 		}
 		
 		/**
 		 * 키값에 대한 공통데이터 조회
 		 * **/
 		private function onSelectedWelFareDetail():void
 		{
	 		var proxy:WelfareDetailProxy = facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy;
	 		proxy.load(Gkey);
 		}
 		
 		private function itemDel(event:WelfareItemEvent):void{
 			view.welfareDetailList.removeItemAt(event.itemIdx);
 			if(view.welfareDetailList.length < 1){
 				addRecord();
 			}
 		}
 		
		/***
		 * 항목추가
		 * */
 		private function onClickAddRecord(e:Event):void
 		{
 			addRecord();
 		}
 		
 		private function addRecord():void
 		{
 			var vo:ReqWelfareVO = new ReqWelfareVO();
 			vo.PERNR = Variables.myPernr;
 			vo.IDATE = DateUtil.todayNoTime();
 			vo.UDATE = DateUtil.todayNoTime();
 			vo.BNFAMT = 0;
 			view.welfareDetailList.addItem(vo);
 		}
 		
 		/***
 		 * 항목삭제
 		 * **/
 		private function onDelRecord(event:Event):void
 		{
			for (var i:int=0; i<view.welfareDetailList.length; i++)
			{
				if(view.welfareDetailList.getItemAt(i).del) {
					view.welfareDetailList.removeItemAt(i--);
				}
			} 			
			if(view.welfareDetailList.length==0) {
	 			addRecord();
			}
 		}
 		
 		/****
 		 * 계좌정보 조회
 		 * **/
 		 private function bankListLoad():void{
 		 	var proxyData:WelfareDetailProxy = facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy;
 			proxyData.accountLoad(Variables.myPernr);
 		 }
		
 		
 		/***
 		 * 계좌관리 팝업 호출
 		 * **/
 		private function onOpenAccountControl(event:Event):void{
 			var form:IFlexDisplayObject = PopUpManager.createPopUp(view, BankAccountView, true);
 			PopUpManager.centerPopUp(form);
 			view.setFocus();
 			var reqMediator:BankAccountMediator = new BankAccountMediator(form);
 			facade.registerMediator(reqMediator);
 		}
 		
 		private function onCancel(event:Event):void
 		{
 			//facade.sendNotification(WelfareFacade.CANCEL_WELFARE, this);
			bActivated = false;
		 		facade.sendNotification(WelfareFacade.CLOSED_REQ_VIEW, this); 			
 		}
 		
 		/***
 		 * 저장버튼 클릭
 		 * **/
 		private function onConfirm(event:Event):void{
 			if(!moneyValidation()) return;
 			
 			bWaitingApproval = false;;
 			modifyNinsert();
 		}

 		/***
 		 * 승인요청 클릭
 		 * **/
 		private var tmpVO:ReqWelfareVO; 	
 		private function onApproval(event:Event):void{
 			if(!moneyValidation()) return;
 			
 			bWaitingApproval = true;
 			//var detailList:Array = toJsonFormatDetailList(view.welfareDetailList);
 			tmpVO = view.welfareDetailList.getItemAt(0) as ReqWelfareVO; 			 
 			modifyNinsert();
 		} 		
 		
 		
 		private function moneyValidation():Boolean{
 			var totalNum:Number = 0;
 			for(var i:int = 0; i < view.welfareDetailList.length; i++){
 				
 				//view.welfareDetailList[i].APGBN = view.
 				
 				if(StringUtil.NVL(view.welfareDetailList[i].IDATE) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_01");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].UDATE) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_02");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].CAFGBN) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_03");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].CAFTY) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_04");
 					return false;
 				}else if(view.welfareDetailList[i].BNFAMT == "0" || StringUtil.NVL(view.welfareDetailList[i].BNFAMT) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_05");
 					return false;
 				}else if(sumUseMoney() > restMoney){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_06",[ NumberUtil.NumberFormat(restMoney)]);
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].STGBN) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_07");
 					return false;
 				} 			 				
 				/* 
 				0411
 				사업자번호 제거
 				else if(StringUtil.NVL(view.welfareDetailList[i].STCD2) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_08");
 					return false;
 				}
 				 
 				else if(StringUtil.NVL(view.welfareDetailList[i].STCD2).length != 10){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_09");
 					return false;
 				}
 				*/
 				
 				else if(StringUtil.NVL(view.welfareDetailList[i].COMNM) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_10");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].APGBN) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_11");
 					return false;
 				}/*else if(StringUtil.NVL(view.welfareDetailList[i].CARDNO) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_12");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].CARDNO).length != 16){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_13");
 					return false;
 				}else if(StringUtil.NVL(view.welfareDetailList[i].APNO) == ""){
 					CommonAlert.showMessage(commonFacade.bundle, "ALERT_INVALID_INPUT_14");
 					return false;
 				} */
 				
 			}
 			return true;
 		}
 		
 		private function sumUseMoney():Number{
 			var totalNum:Number = 0;
	 		for(var i:int = 0; i < view.welfareDetailList.length; i++){
	 			totalNum += Number(view.welfareDetailList[i].BNFAMT);
	 		}
	 		return totalNum;
	 	}

 		// 가능한 신청일 체크  	
 		private function modifyNinsert():void {
 			var d:Date = view.reqRdr2[0].D_UDATE.selectedDate;
			var sTargetDate:String = DateUtil.toYYYYMMString(d)+"01"; 			
			var sNowDate:String = DateUtil.toBasicString(DateUtil.firstDateofThisMonth());

	 		var proxy:WelfareDetailProxy = facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy;
	 		proxy.validReqDay(sTargetDate, sNowDate);	 					
 		}
 			
 		private function modifyNinsert2():void
 		{
	 		var proxy:WelfareDetailProxy = facade.retrieveProxy(WelfareDetailProxy.NAME) as WelfareDetailProxy;
	 		var yearProxy:WelfareYearProxy = facade.retrieveProxy(WelfareYearProxy.NAME) as WelfareYearProxy;
			
	 		var detailList:Array = toJsonFormatDetailList(view.welfareDetailList);
	 		var masterList:Array = new Array();
	 		var master:Object = new Object();
//0620 계좌삭제	 		
//	 		master.BNKSA = view.cbType.selectedItem.CODE;
//	 		master.BNKTX = view.cbType.selectedItem.LABEL;
/* 
	 		master.BNKSA = view.detailMaster.BNKSA;
	 		master.BNKTX = view.detailMaster.BNKTX;
	 		master.BANKL = view.detailMaster.BANKL;
	 		master.BANKA = view.detailMaster.BANKA;
	 		master.BANKN = view.detailMaster.BANKN;
	 		master.EMFTX = view.detailMaster.EMFTX;
 */
 			//view.detailMaster
	 		master.BNKSA = view.bankAccount.BNKSA;	 		
	 		// 값이 없음 . 
	 		master.BNKTX = '';
	 		
	 		master.BANKL = view.bankAccount.BANKL;
	 		master.BANKA = view.bankAccount.BANKA;
	 		master.BANKN = view.bankAccount.BANKN;
	 		master.EMFTX = view.bankAccount.EMFTX;	 		 
	 		
	 		
	 		masterList.push(master);
	 		if(Gkey == null || Gkey == ""){
	 			trace("INSERT");
		 		//proxy.insert(Variables.myPernr, yearProxy.yearList.getItemAt(yearProxy.yearList.length-1).toString(), detailList, masterList);
		 		proxy.insert(Variables.myPernr, cbYear, detailList, masterList);
		 		
	 		}else{
	 			trace("UPDATE");
	 			//proxy.update(Variables.myPernr, yearProxy.yearList.getItemAt(yearProxy.yearList.length-1).toString(), detailList, masterList, Gkey);
	 			proxy.update(Variables.myPernr, cbYear, detailList, masterList, Gkey);
	 			
	 		}
 		}
 		
 		private function toJsonFormatDetailList(list:ArrayCollection):Array {
	 		var detailList:Array = new Array();
	 		for each(var vo:ReqWelfareVO in view.welfareDetailList) 
	 		{
	 			var tmp:Object = new Object;
	 			tmp.PERNR		= vo.PERNR;			//사원번호
	 			tmp.ENAME		= vo.ENAME;			//사원명 
	 			tmp.IDATE		= DateUtil.toBasicString(vo.IDATE);	//신청일
	 			tmp.UDATE		= DateUtil.toBasicString(vo.UDATE); //사용일
	 			tmp.SEQNO		= vo.SEQNO;			//사원번호
	 			tmp.CAFGBN		= vo.CAFGBN;		//사용유형
	 			tmp.CAFGTX		= vo.CAFGTX;		//사용유형명
	 			tmp.CAFTY		= vo.CAFTY;			//사용항목
	 			tmp.CAFTX		= vo.CAFTX;			//사용항목명
	 			tmp.DTEXT		= vo.DTEXT;			//상세내역
	 			tmp.BNFAMT		= vo.BNFAMT/100;		//금액

	 			tmp.STGBN		= vo.STGBN;			//거래구분(국내,국외) <거래처정보>
	 			tmp.STGBN_TX	= vo.STGBN_TX;		//거래구분(국내,국외) <거래처정보>
	 			tmp.STCD2		= vo.STCD2;			//사업자등록번호 (사업자번호 )
	 			tmp.COMNM		= vo.COMNM;			//업체명 ( 사업장명 )
	 			tmp.APGBN		= vo.APGBN;			//거래결재유형 ( 거래결재정보 )
	 			tmp.APGBN_TX	= vo.APGBN_TX;		//거래결재유형 ( 거래결재정보 )
	 			tmp.CARDNO		= vo.CARDNO;		//카드번호
	 			tmp.APNO		= vo.APNO;			//승인번호
	 			detailList.push(tmp);
	 		}
	 		return detailList;
 		}
 		
 		/***
 		 * 저장실패시 /100한 BNFAMT 이전으로 return 
 		 * **/
 		private function returnAmt():void{
 			for(var i:int = 0; i < view.welfareDetailList.length; i++)
	 		{
	 			//view.welfareDetailList[i].BNFAMT *= 100; 
	 		}
 		}
 
 		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		* 본 Class에서 처리해야할 Noti들을 등록한다.
		* 
		* @param
		* @return void
		*/
		override public function listNotificationInterests():Array 
		{
			return [
					WelfareFacade.LOAD_VALIDREQDAYRESULT_COMPLETE,
					WelfareFacade.LOAD_WELFARE_DETAIL_COMPLETE,
					WelfareFacade.SAVE_WELFARE_COMPLETE,
					WelfareFacade.SAVE_WELFARE_FAILED,
					WelfareFacade.UPDATE_WELFARE_COMPLETE,
					WelfareFacade.UPDATE_WELFARE_FAILED,
					WelfareFacade.RELOAD_ACCOUNT_INFO,
					WelfareFacade.RELOAD_BANK_ACCOUNT_COMPLETE,
					WelfareFacade.RELOAD_BANK_ACCOUNT_FAILED,
					RequestApprovalMediator.APPROVAL_COMPLETE
					];
		}
		

		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		private var bWaitingApproval:Boolean = false;
		private var _currentKey:String = "";
		
		override public function handleNotification(note:INotification):void
		{
			switch(note.getName()) 
			{
				// 신청 가능일 가능할때
				case WelfareFacade.LOAD_VALIDREQDAYRESULT_COMPLETE:
					modifyNinsert2();
					break;				
				
				case WelfareFacade.LOAD_WELFARE_DETAIL_COMPLETE:
					view.welfareDetailList = (note.getBody() as WelfareDetailProxy).detailList;
					view.detailMaster = (note.getBody() as WelfareDetailProxy).detailMaster;
 					trace("restMoney1: " + restMoney);
 					trace("sumUseMoney(): " + sumUseMoney());
					restMoney = restMoney + sumUseMoney();
 					trace("restMoney2 : " + restMoney);
					break;
				case WelfareFacade.SAVE_WELFARE_COMPLETE:
				
					// 승인요청하여 결재창이 뜨도록. 
					if(bWaitingApproval) {
						var obj:Object = note.getBody();
						_currentKey = obj.O_GWAREKEY;
						execApproval(_currentKey);
					}
					// 임시저장.
					else {
 						bActivated = false;
						facade.sendNotification(WelfareFacade.CLOSED_REQ_VIEW, this);
					}
					bWaitingApproval = false;				
					break;
				case WelfareFacade.SAVE_WELFARE_FAILED:
					bWaitingApproval = false;
					CommonAlert.showMessage(commonFacade.bundle, (note.getBody() as WelfareDetailProxy).msgStr);
					returnAmt();
					break;
				case WelfareFacade.RELOAD_ACCOUNT_INFO:
					//bankInfoLoad(view.cbType.selectedIndex);
					bankInfoLoad();
					bankListLoad();
					break;
				case WelfareFacade.UPDATE_WELFARE_COMPLETE:

				
					// 승인요청하여 결재창이 뜨도록. 
					if(bWaitingApproval) {
						var obj:Object = note.getBody();
						_currentKey = obj.O_GWAREKEY;
						execApproval(_currentKey);
					}
					// 임시저장.
					else {
 						bActivated = false;
 						CommonAlert.showMessage(commonFacade.bundle, "ALERT_SUCCEED_MODIFY");
						facade.sendNotification(WelfareFacade.CLOSED_REQ_VIEW, this);
					}
					bWaitingApproval = false;				
					break;
									
 					//CommonAlert.showMessage(commonFacade.bundle, "ALERT_SUCCEED_MODIFY");
					//facade.sendNotification(WelfareFacade.CLOSED_REQ_VIEW, this);
					break;
				case WelfareFacade.UPDATE_WELFARE_FAILED:
					CommonAlert.showMessage(commonFacade.bundle, (note.getBody() as WelfareDetailProxy).msgStr);
					returnAmt();
					break;	
				case WelfareFacade.RELOAD_BANK_ACCOUNT_COMPLETE:
					this.defaultBank = (note.getBody() as WelfareDetailProxy).defaultBank;
	   				this.additionBank = (note.getBody() as WelfareDetailProxy).additionBank;
					//bankInfoLoad(view.cbType.selectedIndex);
					bankInfoLoad();
					break;	
				case WelfareFacade.RELOAD_BANK_ACCOUNT_FAILED:
					CommonAlert.showMessage(commonFacade.bundle, (note.getBody() as WelfareDetailProxy).msgStr);
					break;
				case RequestApprovalMediator.APPROVAL_COMPLETE:					// 결재 요청  성공
					bActivated = false;
		 			facade.sendNotification(WelfareFacade.CLOSED_REQ_VIEW, this);
					break;						
				default:
					//trace(this.instanceID+"에서 처리 안된 Noti가 검출됨 : " + note.getBody());
					break;
			}
		}
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Utility Functions
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
        private function get view():ReqWelfare
        {
            return viewComponent as ReqWelfare;
        }
        
        
        
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Data Access Functions....
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////

		private function execApproval(key:String):void
		{
 			var approval:RequestApprovalMediator = facade.retrieveMediator(RequestApprovalMediator.NAME) as RequestApprovalMediator;
 			if(approval==null) {
 				approval = new RequestApprovalMediator(view, "09");
 				facade.registerMediator(approval);
 			}
 			bActivated = false;
 			
 			var appProxy:WelfareApprovalProxy = facade.retrieveProxy(WelfareApprovalProxy.NAME) as WelfareApprovalProxy;
  			appProxy.key = key;
 			appProxy.dataProvider = tmpVO;
 			approval.execRequest(view, appProxy);   
		}        
	}
}